From 660591fb407dab23b3b5ad8da139929ae7c3ba6f Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 4 Nov 2005 23:11:41 +0000 Subject: [PATCH] Add 'nukedata' filter to remove waypoints, tracks, and routes. --- gpsbabel/filter_vecs.c | 6 ++++ gpsbabel/nukedata.c | 62 ++++++++++++++++++++++++++++++++++++++++++ gpsbabel/route.c | 28 +++++++++++++------ 3 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 gpsbabel/nukedata.c diff --git a/gpsbabel/filter_vecs.c b/gpsbabel/filter_vecs.c index 3a5568f85..0249b3a24 100644 --- a/gpsbabel/filter_vecs.c +++ b/gpsbabel/filter_vecs.c @@ -39,6 +39,7 @@ extern filter_vecs_t sort_vecs; extern filter_vecs_t stackfilt_vecs; extern filter_vecs_t trackfilter_vecs; extern filter_vecs_t discard_vecs; +extern filter_vecs_t nuke_vecs; static fl_vecs_t filter_vec_list[] = { @@ -97,6 +98,11 @@ fl_vecs_t filter_vec_list[] = { "discard", "Remove unreliable points with high hdop or vdop" }, + { + &nuke_vecs, + "nuketypes", + "Remove all waypoints, tracks, or routes" + }, { NULL, NULL, diff --git a/gpsbabel/nukedata.c b/gpsbabel/nukedata.c new file mode 100644 index 000000000..3b2f96361 --- /dev/null +++ b/gpsbabel/nukedata.c @@ -0,0 +1,62 @@ +/* + + nukedata: remove all (waypoint|tracks|routes) from the stream. + + Copyright (C) 2005 Robert Lipe robertlipe@usa.net + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + +#include "defs.h" +#include "filterdefs.h" + +#define MYNAME "nukedata" + +static char *nukewpts, *nuketrks, *nukertes; + +static +arglist_t nuke_args[] = { + {"waypoints", &nukewpts, "Remove all waypoints from data stream.", + "0", ARGTYPE_BOOL} , + {"tracks", &nuketrks, "Remove all tracks from data stream.", + "0", ARGTYPE_BOOL} , + {"routes", &nukertes, "Remove all routes from data stream.", + "0", ARGTYPE_BOOL} , + {0, 0, 0, 0, 0} +}; + +static void +nuke_process(void) +{ + if (nukewpts) { + waypt_flush_all(); + } + if (nuketrks) { + route_flush_all_tracks(); + } + if (nukertes) { + route_flush_all_routes(); + } +} + +filter_vecs_t nuke_vecs = { + NULL, + nuke_process, + NULL, + NULL, + nuke_args +}; + diff --git a/gpsbabel/route.c b/gpsbabel/route.c index 121c1c1e0..52c76b412 100644 --- a/gpsbabel/route.c +++ b/gpsbabel/route.c @@ -228,8 +228,8 @@ track_disp_all(route_hdr rh, route_trl rt, waypt_cb wc) common_disp_all(&my_track_head, rh, rt, wc); } -void -route_flush(queue *head) +static void +route_flush_q(queue *head) { queue *elem, *tmp; queue *q; @@ -241,15 +241,27 @@ route_flush(queue *head) } void -route_flush_all() +route_flush_all_routes(void) { - route_flush(&my_route_head); - route_flush(&my_track_head); + route_flush_q(&my_route_head); rte_head_ct = 0; - trk_head_ct = 0; rte_waypts = 0; } +void +route_flush_all_tracks(void) +{ + route_flush_q(&my_track_head); + trk_head_ct = 0; +} + +void +route_flush_all() +{ + route_flush_all_tracks(); + route_flush_all_routes(); +} + void route_backup(unsigned int *count, queue **head_bak) { @@ -332,7 +344,7 @@ route_restore(unsigned int count, queue *head_bak) { if (head_bak == NULL) return; - route_flush(&my_route_head); + route_flush_q(&my_route_head); QUEUE_INIT(&my_route_head); QUEUE_MOVE(&my_route_head, head_bak); xfree(head_bak); @@ -388,7 +400,7 @@ track_restore(unsigned int count, queue *head_bak) { if (head_bak == NULL) return; - route_flush(&my_track_head); + route_flush_q(&my_track_head); QUEUE_INIT(&my_track_head); QUEUE_MOVE(&my_track_head, head_bak); xfree(head_bak); -- 2.30.2